//
//  DestinationDetailViewController.m
//  CommonFrame
//
//  Created by Bang-guo on 15/7/25.
//  Copyright (c) 2015年 guobang. All rights reserved.
//

#import "DestinationDetailViewController.h"

@interface DestinationDetailViewController ()

@end

@implementation DestinationDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = self.des.title;
    self.destinationDetailS = [[DestinationDetailScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 113)];
    self.destinationDetailS.myDelegate = self;
    [self.view addSubview:self.destinationDetailS];
    self.allArray = [NSMutableArray array];
    self.navigationItem.title = self.des.name;
    [self getDataValue];
    self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.HUD.labelText = @"正在加载中...";
    [self.HUD show:YES];
    
}

-(void)sendDestinationModle:(DestinationDetail *)des {
    NearbyDetail *detail = [[NearbyDetail alloc] init];
    detail.placeId = des.placeId;
    detail.type = des.type;
    NearbyPhotoViewController *nearbyPVC = [[NearbyPhotoViewController alloc] init];
    nearbyPVC.nearbyDetail = detail;
    [self.navigationController pushViewController:nearbyPVC animated:YES];
    
}

-(void)getDataValue {
    
    NSString *str_url = [NSString stringWithFormat:@"http://api.breadtrip.com/destination/place/%@/%@/", self.des.type, self.des.placeId];
    
    
    [AFNGetDataValue getDataAFN:str_url block:^(NSMutableDictionary *dataDic) {
        
//        NSLog(@"%@", dataDic);
        DestinationDetail *des1 = [[DestinationDetail alloc] init];
        des1.name = [dataDic objectForKey:@"name"];
        des1.visited_count = [NSString stringWithFormat:@"%@", [dataDic objectForKey:@"visited_count"]];
        des1.wish_to_go_count = [NSString stringWithFormat:@"%@", [dataDic objectForKey:@"wish_to_go_count"]];
        des1.shr_image = [[[dataDic objectForKey:@"share_args"] objectForKey:@"default"] objectForKey:@"shr_image"];
        des1.placeId = [NSString stringWithFormat:@"%@", [dataDic objectForKey:@"id"]];
        des1.type = [NSString stringWithFormat:@"%@", [dataDic objectForKey:@"type"]];
        NSMutableArray *array = [NSMutableArray arrayWithArray:[dataDic objectForKey:@"hottest_places"]];
        for (NSMutableDictionary *dic in array) {
            

            NSString *str = [dic objectForKey:@"photo"];

            [self.allArray addObject:str];
        }
        
        [self.destinationDetailS createSubViews:des1 andArray:self.allArray];
        [self.HUD hide:YES];
        
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
